import cv2
import numpy as np
input_file = 'test.jpg'
img = cv2.imread(input_file)
imgray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
ret,thresh = cv2.threshold(imgray,127,255,0)
contours,hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
cv2.namedWindow(input_file,cv2.WINDOW_NORMAL|cv2.WINDOW_KEEPRATIO)
#cv2.resizeWindow(input_file,400,300)
#cv2.namedWindow('test',cv2.WINDOW_AUTOSIZE)
#for index in range(len(contours)):
#    img=cv2.drawContours(img,[contours[index]],-1,(0,255,0),10)

img=cv2.drawContours(img,[contours[0]],-1,(0,255,0),20)
print(contours[0])
#print(hierarchy[0].size)
cv2.imshow(input_file,img)
cv2.waitKey(10000)
cv2.destroyAllWindows()
